package com.daka.entity;

import com.daka.tools.DKQConstant;
import com.daka.tools.DateUtil;
import lombok.Data;
import lombok.ToString;
import org.apache.ibatis.type.Alias;

import java.util.Date;

@Data
@ToString
@Alias(value = "groupVolunteer")
public class GroupVolunteer {

    private Long id;
    private Date createTime;
    private Integer delStatus;
    private String demo;
    private Integer role;
    private Integer status;
    private Long groupId;
    private Long volunteerId;
    private String refuseCase;
    private Long times;


    public static GroupVolunteer build(MemberOrg1 memberOrg1) {
        GroupVolunteer groupVolunteer = new GroupVolunteer();
        try {
            if (memberOrg1.getCreatetime() != null) {
                //创建时间、申请时间
                groupVolunteer.setCreateTime(DateUtil.getDateFormString(memberOrg1.getCreatetime()));
            }
        } catch (Exception e) {
            e.printStackTrace();
            groupVolunteer.setCreateTime(new Date());
        }
        groupVolunteer.setDelStatus(DKQConstant.DEL_NO);
        groupVolunteer.setDemo(memberOrg1.getDemo());

        if (memberOrg1.getUserType() != null) {
            if (memberOrg1.getUserType() == 2) {
                groupVolunteer.setRole(1);//管理员
            } else {
                groupVolunteer.setRole(0);//普通志愿者
            }
            if (memberOrg1.getAuthor() != null && memberOrg1.getAuthor().equalsIgnoreCase("11111")) {
                groupVolunteer.setRole(2);//创建者
            }
        } else {
            groupVolunteer.setRole(0);
        }
        groupVolunteer.setStatus(memberOrg1.getStatus());
        groupVolunteer.setTimes(0l);//
        return groupVolunteer;
    }
}